package com.hans.myscanner.Scanner.Activity;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ToggleButton;

import com.google.zxing.client.android.CaptureActivity;
import com.hans.myscanner.R;

public class ScanSubActivity extends CaptureActivity {
    private View addBtn;
    private ToggleButton flashLightBtn;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        findView();
        initView();
    }

    @Override
    protected void onResume() {
        super.onResume();
        showViewFindView(false);
    }

    protected void findView() {
        getRootLayoutView().addView(View.inflate(this,R.layout.activity_scan,null));
        addBtn = findViewById(R.id.ad_btn);
        flashLightBtn = (ToggleButton) findViewById(R.id.flash_light_toggle);

//        new AdWindow(ScanSubActivity.this).showAtLocation(addBtn, Gravity.BOTTOM,0,50);
    }

    protected void initView() {
        addBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO: 2016/6/27  从手机相册选取一张二维码相片进行识别
            }
        });

        flashLightBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                cameraManager.toggleCameraFlashLight(isChecked);
            }
        });
    }

//    class AdWindow extends PopupWindow{
//        public AdWindow(Context context) {
//            super(context);
//            setContentView(View.inflate(ScanSubActivity.this,R.layout.item_history_listview_item,null));
//        }
//    }
}
